Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

aescpp.h

Go to the documentation of this file.
00001 
00002 /*
00003  ---------------------------------------------------------------------------
00004  Copyright (c) 2003, Dr Brian Gladman <brg@gladman.me.uk>, Worcester, UK.
00005  All rights reserved.
00006 
00007  LICENSE TERMS
00008 
00009  The free distribution and use of this software in both source and binary
00010  form is allowed (with or without changes) provided that:
00011 
00012    1. distributions of this source code include the above copyright
00013       notice, this list of conditions and the following disclaimer;
00014 
00015    2. distributions in binary form include the above copyright
00016       notice, this list of conditions and the following disclaimer
00017       in the documentation and/or other associated materials;
00018 
00019    3. the copyright holder's name is not used to endorse products
00020       built using this software without specific written permission.
00021 
00022  ALTERNATIVELY, provided that this notice is retained in full, this product
00023  may be distributed under the terms of the GNU General Public License (GPL),
00024  in which case the provisions of the GPL apply INSTEAD OF those given above.
00025 
00026  DISCLAIMER
00027 
00028  This software is provided 'as is' with no explicit or implied warranties
00029  in respect of its properties, including, but not limited to, correctness
00030  and/or fitness for purpose.
00031  ---------------------------------------------------------------------------
00032  Issue Date: 1/06/2003
00033 
00034  This file contains the definitions required to use AES (Rijndael) in C++.
00035 */
00036 
00037 #ifndef _AESCPP_H
00038 #define _AESCPP_H
00039 
00040 #include "aes.h"
00041 
00042 class AESencrypt
00043 {   aes_encrypt_ctx cx;
00044 public:
00045     AESencrypt(void)    
00046             { };
00047 #ifdef  AES_128
00048     AESencrypt(const unsigned char in_key[])
00049             { aes_encrypt_key128(in_key, cx); }
00050     void key128(const unsigned char in_key[])
00051             { aes_encrypt_key128(in_key, cx); }
00052 #endif
00053 #ifdef  AES_192
00054     void key192(const unsigned char in_key[])
00055             { aes_encrypt_key192(in_key, cx); }
00056 #endif
00057 #ifdef  AES_256
00058     void key256(const unsigned char in_key[])
00059             { aes_encrypt_key256(in_key, cx); }
00060 #endif
00061 #ifdef  AES_VAR
00062     void key(const unsigned char in_key[], int key_len)
00063             { aes_encrypt_key(in_key, key_len, cx); }
00064 #endif
00065     void encrypt(const unsigned char in_blk[], unsigned char out_blk[]) const
00066             { aes_encrypt(in_blk, out_blk, cx);  }
00067 };
00068 
00069 class AESdecrypt
00070 {   aes_decrypt_ctx cx;
00071 public:
00072     AESdecrypt(void)    
00073             { };
00074 #ifdef  AES_128
00075     AESdecrypt(const unsigned char in_key[])
00076             { aes_decrypt_key128(in_key, cx); }
00077     void key128(const unsigned char in_key[])
00078             { aes_decrypt_key128(in_key, cx); }
00079 #endif
00080 #ifdef  AES_192
00081     void key192(const unsigned char in_key[])
00082             { aes_decrypt_key192(in_key, cx); }
00083 #endif
00084 #ifdef  AES_256
00085     void key256(const unsigned char in_key[])
00086             { aes_decrypt_key256(in_key, cx); }
00087 #endif
00088 #ifdef  AES_VAR
00089     void key(const unsigned char in_key[], int key_len)
00090             { aes_decrypt_key(in_key, key_len, cx); }
00091 #endif
00092     void decrypt(const unsigned char in_blk[], unsigned char out_blk[]) const
00093             { aes_decrypt(in_blk, out_blk, cx);  }
00094 };
00095 
00096 #endif

Generated on Mon Sep 12 19:58:18 2005 for Destiny3D by doxygen1.3-rc3